﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPFCouse
{
    /// <summary>
    /// TextBoxWindow.xaml 的交互逻辑
    /// </summary>
    public partial class TextBoxWindow : Window
    {
        public TextBoxWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            txtName.Text = "admin";
        }

        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string name = txtName.Text;//用户名

            if(name=="")
            {
                lblMsg.Content = "请输入用户名！";
                return;
            }
            //登录过程。。。。。。

        }

        private void txtName_TextChanged(object sender, TextChangedEventArgs e)
        {
            if(txtName.Text.Length>4)
            {
                lblMsg.Content = "用户名长度过长！";
                return;
            }
            else
            {
                lblMsg.Content = "";
            }
        }
    }
}
